-
Notifications
You must be signed in to change notification settings - Fork 556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: authentication flow should abort early #888
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi
if you send an unauthorized request it will not reach to the any endpoint in internal/http/routes/api/v1/bookmarks.go
Why is it important?
in #885 for public bookmarks you can't accesses readable content bemuse your request not reach to the endpoint (if be unauthorized)
you can test that in other way
send a update cache request to the
http://127.0.0.1:8080/api/v1/bookmarks/cache
if you are unauthorized than you get 401 but this status code not came from this line
shiori/internal/http/routes/api/v1/bookmarks.go
Lines 70 to 73 in c77a542
if !ctx.UserIsLogged() { | |
response.SendError(c, http.StatusForbidden, nil) | |
return | |
} |
it force us to all api in internal/http/routes/api/v1/bookmarks.go
be authorize (and public status be pointless on endpoint in there)
dose you want this?
Right now all handlers under the bookmark endpoint require authentication, so that's good as it is. When we add new mixed handlers we could add the middleware just above the endpoints that require it. Is this something you need for your PR? |
@Monirzadeh Check dff17e1 |
Ugh, now I remember why I did it the other way, routes were easier to test. |
so for example if i need user can acsses readable content of public bookmark (in unauthorized mode) i can't put that in thinking about an app on phone that user can browse public bookmark from multiple shiori server. |
in long term i am thinking about something that user can share there bookmarks with each other (if they want and be disable by default). it is not a mature idea right now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is fine to me right now.
we can spend time in that specific situation if it necessary later.
just please fix that failed unit tests.
thanks for this fix 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so with this new change we should remove this line too
shiori/internal/http/routes/api/v1/bookmarks.go
Lines 70 to 73 in c77a542
if !ctx.UserIsLogged() { | |
response.SendError(c, http.StatusForbidden, nil) | |
return | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks 👍
testutil.TestResponse